package com.chinaunicom.structure.adapter.twoway;

/**
 * @author liry
 * @version 1.0
 * @date Created on 2022/7/21 10:12
 * Description: 适配器类: 需要实现适配者类
 */
public class TwoWayAdapter implements TwoWayTarget, TwoWayAdaptee{
    
    private TwoWayAdaptee twoWayAdaptee;
    
    private TwoWayTarget twoWayTarget;
    
    public TwoWayAdapter(TwoWayAdaptee twoWayAdaptee){
        this.twoWayAdaptee = twoWayAdaptee;
    }
    
    public TwoWayAdapter(TwoWayTarget twoWayTarget){
        this.twoWayTarget = twoWayTarget;
    }


    @Override
    public void specificRequest() {
        System.out.println("目标执行适配器方法-------");
        twoWayTarget.request();
    }

    @Override
    public void request() {
        System.out.println("适配器执行目标方法-------");
        twoWayAdaptee.specificRequest();
    }
}
